
// 将数据存入本地session
export const setItem = (key, value) => {
    if(typeof value === 'object') {
        value = JSON.stringify(value)
    }
    sessionStorage.setItem(key, value)
}

// 从本地取出数据
export const getItem = key => {
    let value = sessionStorage.getItem(key)
    try {
        value = JSON.parse(value)
        return value
    } catch (err) {
        return value
    }
}

// 删除本地数据
export const removeItem = key => {
    sessionStorage.removeItem(key)
}